<?php

/**
 * Solution form base class.
 *
 * @method Solution getObject() Returns the current form's model object
 *
 * @package    rrtk
 * @subpackage form
 * @author     irh
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseSolutionForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'               => new sfWidgetFormInputHidden(),
      'user_profile_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('UserProfile'), 'add_empty' => false)),
      'title'            => new sfWidgetFormInputText(),
      'short_content'    => new sfWidgetFormInputText(),
      'content'          => new sfWidgetFormTextarea(),
      'slug'             => new sfWidgetFormInputText(),
      'language_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Language'), 'add_empty' => true)),
      'base_solution_id' => new sfWidgetFormInputText(),
      'reviews_image_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('ReviewsImage'), 'add_empty' => true)),
      'main_review_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('MainReview'), 'add_empty' => true)),
      'created_at'       => new sfWidgetFormDateTime(),
      'updated_at'       => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'               => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'user_profile_id'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('UserProfile'))),
      'title'            => new sfValidatorString(array('max_length' => 255)),
      'short_content'    => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'content'          => new sfValidatorString(),
      'slug'             => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'language_id'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Language'), 'required' => false)),
      'base_solution_id' => new sfValidatorInteger(array('required' => false)),
      'reviews_image_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('ReviewsImage'), 'required' => false)),
      'main_review_id'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('MainReview'), 'required' => false)),
      'created_at'       => new sfValidatorDateTime(),
      'updated_at'       => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('solution[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Solution';
  }

}
